﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace FrogEngine
{
	public abstract class ModelGameEntityBase : GameEntityBase3D, IHasModel
	{
		public ModelGameEntityBase(IEngine engine, string modelAssetName)
			: base(engine)
		{
			this.modelAsset = modelAssetName;

			Services.Add(engine.GetService<GameContentService>());
			Services.Add(engine.GetService<RenderService>());
			Services.Add(engine.GetService<UpdateEntityService>());
			cameraService = engine.GetService<ICameraService>();

			foreach (var service in Services)
				service.Subscribe(this);
		}

		protected ICameraService cameraService;

		public override abstract void Update(GameTime gameTime);

		public Model Model { get; protected set; }

		public abstract void Render(GameTime gameTime);

		private ContentManager contentManager;
		public ContentManager ContentManager
		{
			get { return contentManager; }
			set { contentManager = value; }
		}

		protected string modelAsset;
		public virtual IEnumerable<string> AssetNames()
		{
			var list = new List<string>();
			list.Add(modelAsset);
			return list;
		}

		public abstract void LoadContent();
	}
}
